

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Building a Simple PCL Interface for Python &mdash; Industrial Training  documentation</title>
  

  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  

  
    <link rel="stylesheet" href="../../_static/override.css" type="text/css" />
  

  
        <link rel="index" title="Index"
              href="../../genindex.html"/>
        <link rel="search" title="Search" href="../../search.html"/>
    <link rel="top" title="Industrial Training  documentation" href="../../index.html"/>
        <link rel="next" title="OpenCV Image Processing (Python)" href="OpenCV-in-Python.html"/>
        <link rel="prev" title="Introduction to STOMP" href="Introduction-to-STOMP.html"/> 

  
  <script src="../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">
  
  <script src="../../_static/js/clipboard.min.js"></script>

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-nav-search">
        

        
          <a href="../../index.html" class="icon icon-home">
        

          ROS-Industrial Training Material<br/>kinetic

        
        </a>

        
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

        
      </div>

      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
        
          
          
              <ul>
<li class="toctree-l1"><a class="reference internal" href="../setup/PC-Setup---ROS-Kinetic.html">PC Setup</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../setup/PC-Setup---ROS-Kinetic.html#virtual-machine-configuration-recommended">Virtual Machine Configuration (<strong>Recommended</strong>)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../setup/PC-Setup---ROS-Kinetic.html#limitations-of-virtual-box">Limitations of Virtual Box</a></li>
<li class="toctree-l3"><a class="reference internal" href="../setup/PC-Setup---ROS-Kinetic.html#common-vm-issues">Common VM Issues</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../setup/PC-Setup---ROS-Kinetic.html#direct-linux-pc-configuration-not-recommended">Direct Linux PC Configuration (<strong>NOT Recommended</strong>)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../setup/PC-Setup---ROS-Kinetic.html#configuration-check">Configuration Check</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference external" href="http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-096-introduction-to-c-january-iap-2011/assignments/">MIT Introduction to C++</a></li>
<li class="toctree-l1"><a class="reference external" href="http://mindview.net/Books/TICPP/ThinkingInCPP2e.html">Bruce Eckel Thinking in C++</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../prerequisites/Navigating-the-Ubuntu-GUI.html">Exercise 0.1 - Intro to Ubuntu GUI</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/Navigating-the-Ubuntu-GUI.html#task-0-presentation-slides">Task 0: Presentation Slides</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/Navigating-the-Ubuntu-GUI.html#task-1-familiarize-yourself-with-the-ubuntu-desktop">Task 1: Familiarize Yourself with the Ubuntu Desktop</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/Navigating-the-Ubuntu-GUI.html#task-2-open-and-inspect-an-application">Task 2: Open and Inspect an Application</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/Navigating-the-Ubuntu-GUI.html#task-3-start-an-application-pin-it-to-the-launcher-bar">Task 3: Start an Application &amp; Pin it to the Launcher Bar</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../prerequisites/Exploring-the-Linux-File-System.html">Exercise 0.2 - The Linux File System</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/Exploring-the-Linux-File-System.html#using-the-file-browser-to-navigate">Using the File Browser to Navigate</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/Exploring-the-Linux-File-System.html#making-changes">Making Changes</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../prerequisites/Exploring-the-Linux-File-System.html#copying-moving-and-removing-files">Copying, Moving, and Removing Files</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html">Starting the Terminal</a></li>
<li class="toctree-l1"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#navigating-directories-and-listing-files">Navigating Directories and Listing Files</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#prepare-your-environment">Prepare your environment</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#ls-command">ls Command</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#pwd-and-cd-commands"><code class="docutils literal"><span class="pre">pwd</span></code> and <code class="docutils literal"><span class="pre">cd</span></code> Commands</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#altering-files">Altering Files</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#mv-command">mv Command</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#cp-command">cp Command</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#rm-command">rm Command</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#mkdir-command">mkdir Command</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#job-management">Job management</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#stopping-jobs">Stopping Jobs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#stopping-out-of-control-jobs">Stopping “Out of Control” Jobs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#showing-process-and-memory-usage">Showing Process and Memory usage</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#editing-text-and-other-gui-commands">Editing Text (and Other GUI Commands)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prerequisites/The-Linux-Terminal.html#running-commands-as-root">Running Commands as Root</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../session1/ROS-Setup.html">Exercise 1.0 - ROS Setup</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session1/ROS-Setup.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/ROS-Setup.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/ROS-Setup.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/ROS-Setup.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/ROS-Setup.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session1/ROS-Setup.html#setup-bashrc">Setup ~/.bashrc</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session1/ROS-Setup.html#starting-roscore">Starting roscore</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session1/Create-Catkin-Workspace.html">Exercise 1.1 - Create a Workspace</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session1/Create-Catkin-Workspace.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Create-Catkin-Workspace.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Create-Catkin-Workspace.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Create-Catkin-Workspace.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Create-Catkin-Workspace.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session1/Create-Catkin-Workspace.html#create-a-catkin-workspace">Create a Catkin Workspace</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session1/Installing-Existing-Packages.html">Exercise 1.2 - Installing Packages</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session1/Installing-Existing-Packages.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Installing-Existing-Packages.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Installing-Existing-Packages.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Installing-Existing-Packages.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Installing-Existing-Packages.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session1/Installing-Existing-Packages.html#install-package-from-apt-repository">Install Package from apt Repository</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session1/Installing-Existing-Packages.html#download-and-build-a-package-from-source">Download and Build a Package from Source</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html">Exercise 1.3 - Packages and Nodes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#create-a-package">Create a Package</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#stop-we-ll-go-through-a-few-more-lecture-slides-before-continuing-this-exercise">STOP!  We’ll go through a few more lecture slides before continuing this exercise.</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#create-a-node">Create a Node</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#run-a-node">Run a Node</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session1/Creating-a-ROS-Package-and-Node.html#challenge">Challenge</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session1/Topics-and-Messages.html">Exercise 1.4 - Topics and Messages</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session1/Topics-and-Messages.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Topics-and-Messages.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Topics-and-Messages.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Topics-and-Messages.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Topics-and-Messages.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session1/Topics-and-Messages.html#add-the-fake-ar-publisher-package-as-a-dependency">Add the fake_ar_publisher Package as a Dependency</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session1/Topics-and-Messages.html#run-a-publisher-node">Run a Publisher Node</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../session1/Topics-and-Messages.html#create-a-subscriber-node">Create a Subscriber Node</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../session2/Services.html">Exercise 2.0 - Services</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session2/Services.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Services.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Services.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Services.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Services.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session2/Services.html#create-service-definition">Create Service Definition</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session2/Services.html#service-server">Service Server</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session2/Services.html#service-client">Service Client</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session2/Services.html#use-new-service">Use New Service</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session2/Actions.html">Exercise 2.1 - Actions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session2/Actions.html#ros-tutorials-for-c-action-client-server-usage">ROS Tutorials for C++ Action Client/Server usage</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session2/Launch-Files.html">Exercise 2.2 - Launch Files</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session2/Launch-Files.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Launch-Files.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Launch-Files.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Launch-Files.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Launch-Files.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session2/Parameters.html">Exercise 2.3 - Parameters</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session2/Parameters.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Parameters.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Parameters.html#further-information-and-resource">Further Information and Resource</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Parameters.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session2/Parameters.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../session3/Intro-to-URDF.html">Exercise 3.0 - Intro to URDF</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session3/Intro-to-URDF.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Intro-to-URDF.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Intro-to-URDF.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Intro-to-URDF.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Intro-to-URDF.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session3/Workcell-XACRO.html">Exercise 3.1 - Workcell XACRO</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session3/Workcell-XACRO.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Workcell-XACRO.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Workcell-XACRO.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Workcell-XACRO.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Workcell-XACRO.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session3/Coordinate-Transforms-using-TF.html">Exercise 3.2 - Transforms using TF</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session3/Coordinate-Transforms-using-TF.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Coordinate-Transforms-using-TF.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Coordinate-Transforms-using-TF.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Coordinate-Transforms-using-TF.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Coordinate-Transforms-using-TF.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session3/Build-a-Moveit!-Package.html">Exercise 3.3 - Build a MoveIt! Package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session3/Build-a-Moveit!-Package.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Build-a-Moveit!-Package.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Build-a-Moveit!-Package.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Build-a-Moveit!-Package.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Build-a-Moveit!-Package.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Build-a-Moveit!-Package.html#using-moveit-with-physical-hardware">Using MoveIt! with Physical Hardware</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session3/Motion-Planning-RVIZ.html">Exercise 3.4 - Motion Planning using RViz</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session3/Motion-Planning-RVIZ.html#launch-the-planning-environment">Launch the Planning Environment</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Motion-Planning-RVIZ.html#plugin-display-options">Plugin Display Options</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Motion-Planning-RVIZ.html#basic-motion">Basic Motion</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session3/Motion-Planning-RVIZ.html#beyond-the-basics">Beyond the Basics</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../session4/Motion-Planning-CPP.html">Exercise 4.0 - Motion Planning using C++</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session4/Motion-Planning-CPP.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Motion-Planning-CPP.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Motion-Planning-CPP.html#further-information-and-resources">3. Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Motion-Planning-CPP.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Motion-Planning-CPP.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session4/Descartes-Path-Planning.html">Exercise 4.1 - Intro to Descartes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#setup-workspace">Setup workspace</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#complete-descartes-node">Complete Descartes Node</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#update-workcell-node">Update Workcell Node</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#test-full-application">Test Full Application</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Descartes-Path-Planning.html#hints-and-help">Hints and Help</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session4/Introduction-to-Perception.html">Exercise 4.2 - Intro to Perception</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session4/Introduction-to-Perception.html#point-cloud-data-file">Point Cloud Data File</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Introduction-to-Perception.html#display-the-point-cloud-in-rviz">Display the point cloud in RViz</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session4/Introduction-to-Perception.html#experiment-with-pcl">Experiment with PCL</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session4/Introduction-to-Perception.html#downsample-the-point-cloud-using-the-pcl-voxel-grid">Downsample the point cloud using the pcl_voxel_grid.</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Introduction-to-Perception.html#extracting-the-table-surface-from-point-cloud-using-the-pcl-sac-segmentation-plane">Extracting the table surface from point cloud using the pcl_sac_segmentation_plane.</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Introduction-to-Perception.html#extracting-the-largest-cluster-on-the-table-from-point-cloud-using-the-pcl-sac-segmentation-plane">Extracting the largest cluster on the table from point cloud using the pcl_sac_segmentation_plane.</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Introduction-to-Perception.html#remove-outliers-from-the-cloud-using-the-pcl-outlier-removal">Remove outliers from the cloud using the pcl_outlier_removal.</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Introduction-to-Perception.html#compute-the-normals-for-each-point-in-the-point-cloud-using-the-pcl-normal-estimation">Compute the normals for each point in the point cloud using the pcl_normal_estimation.</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session4/Introduction-to-Perception.html#mesh-a-point-cloud-using-the-marching-cubes-reconstruction">Mesh a point cloud using the marching cubes reconstruction.</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../demo1/index.html">      Demo 1 - Perception-Driven Manipulation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Introduction.html">Demo 1.0 - Introduction</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Introduction.html#goal">Goal</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Introduction.html#objectives">Objectives</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Inspect-the-package.html">Demo 1.1 - Inspect the &quot;pick_and_place_exercise&quot; Package</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#acquire-and-initialize-the-workspace">Acquire and initialize the Workspace</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#download-source-dependencies">Download source dependencies</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#download-debian-dependencies">Download debian dependencies</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#build-your-workspace">Build your workspace</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#source-the-workspace">Source the workspace</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#locate-and-navigate-into-the-package">Locate and navigate into the package</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#look-into-each-file-in-the-launch-directory">Look into each file in the launch directory</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#look-into-the-config-directory">Look into the config directory</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Inspect-the-package.html#look-into-the-src-directory">Look into the src directory</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Package-Setup.html">Demo 1.2 - Package Setup</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Package-Setup.html#build-package-dependencies">Build Package Dependencies</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Package-Setup.html#import-package-into-qtcreator">Import Package into QTCreator</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Package-Setup.html#open-the-main-thread-source-file">Open the Main Thread Source File</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Bring-up-ROS-system-in-simulation-mode.html">Demo 1.3 - Start in Simulation Mode</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Bring-up-ROS-system-in-simulation-mode.html#run-setup-launch-file-in-simulation-mode-simulated-robot-and-sensor">Run setup launch file in simulation mode (simulated robot and sensor)</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Bring-up-ROS-system-in-simulation-mode.html#setup-for-real-sensor-and-simulated-robot">Setup for real sensor and simulated robot</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Bring-up-ROS-system-in-simulation-mode.html#setup-for-real-robot-and-simulated-sensor-data">Setup for real robot and simulated sensor data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Bring-up-ROS-system-in-simulation-mode.html#setup-for-real-robot-and-real-sensor">Setup for real robot and real sensor</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Initialization-and-global-variables.html">Demo 1.4 - Initialization and Global Variables</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Initialization-and-global-variables.html#application-variables">Application Variables</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Initialization-and-global-variables.html#node-initialization">Node Initialization</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Move-arm-to-wait-position.html">Demo 1.5 - Move Arm to Wait Position</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Move-arm-to-wait-position.html#locate-function">Locate Function</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Move-arm-to-wait-position.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Move-arm-to-wait-position.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Move-arm-to-wait-position.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Open-gripper.html">Demo 1.6 - Open Gripper</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Open-gripper.html#locate-function">Locate Function</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Open-gripper.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Open-gripper.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Open-gripper.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Detect-box-pick-point.html">Demo 1.7 - Detect Box Pick Point</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Detect-box-pick-point.html#locate-function">Locate Function</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Detect-box-pick-point.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Detect-box-pick-point.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Detect-box-pick-point.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Create-pick-moves.html">Demo 1.8 - Create Pick Moves</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Create-pick-moves.html#locate-function">Locate Function</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Create-pick-moves.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Create-pick-moves.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Create-pick-moves.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Pick-up-box.html">Demo 1.9 - Pick Up Box</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Pick-up-box.html#locate-function">Locate Function</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Pick-up-box.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Pick-up-box.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Pick-up-box.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Create-place-moves.html">Demo 1.10 - Create Place Moves</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Create-place-moves.html#locate-function">Locate Function</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Create-place-moves.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Create-place-moves.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Create-place-moves.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo1/Place-box.html">Demo 1.11 - Place Box</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Place-box.html#locate-function">Locate Function</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Place-box.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Place-box.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo1/Place-box.html#api-references">API References</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../demo2/index.html">Demo 2 - Descartes Planning and Execution</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Introduction.html">Demo 2.0 - Introduction</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Introduction.html#goal">Goal</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Introduction.html#objectives">Objectives</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Application-Structure.html">Demo 2.1 - Application Structure</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#acquire-and-initialize-the-workspace">Acquire and initialize the Workspace</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#download-source-dependencies">Download source dependencies</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#download-debian-dependencies">Download debian dependencies</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#build-your-workspace">Build your workspace</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#source-the-workspace">Source the workspace</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#list-all-the-packages-in-the-application">List All the Packages in the Application</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#the-plan-and-run-package">The <code class="docutils literal"><span class="pre">plan_and_run</span></code> package</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#main-application-source-file">Main Application Source File</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#the-demoapplication-class">The DemoApplication Class</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Application-Structure.html#application-launch-file">Application Launch File</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/General-Instructions.html">Demo 2.2 - General Instructions</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/General-Instructions.html#main-objective">Main Objective</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/General-Instructions.html#complete-exercises">Complete Exercises</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/General-Instructions.html#run-demo-in-simulation-mode">Run Demo in Simulation Mode</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/General-Instructions.html#run-demo-on-the-real-robot">Run Demo on the Real Robot</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Load-Parameters.html">Demo 2.3 - Load Parameters</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Load-Parameters.html#locate-exercise-source-file">Locate Exercise Source File</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Load-Parameters.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Load-Parameters.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Load-Parameters.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Initialize-ROS.html">Demo 2.4 - Initialize ROS</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Initialize-ROS.html#locate-exercise-source-file">Locate Exercise Source File</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Initialize-ROS.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Initialize-ROS.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Initialize-ROS.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Initialize-Descartes.html">Demo 2.5 - Initialize Descartes</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Initialize-Descartes.html#locate-exercise-source-file">Locate Exercise Source File</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Initialize-Descartes.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Initialize-Descartes.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Initialize-Descartes.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Move-Home.html">Demo 2.6 - Move Home</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Move-Home.html#locate-exercise-source-file">Locate Exercise Source File</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Move-Home.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Move-Home.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Move-Home.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Generate-a-Semi-Constrained-Trajectory.html">Demo 2.7 - Generate a Semi-Constrained Trajectory</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Generate-a-Semi-Constrained-Trajectory.html#locate-exercise-source-file">Locate exercise source file</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Generate-a-Semi-Constrained-Trajectory.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Generate-a-Semi-Constrained-Trajectory.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Generate-a-Semi-Constrained-Trajectory.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Plan-a-robot-path.html">Demo 2.8 - Plan a Robot Path</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Plan-a-robot-path.html#locate-exercise-source-file">Locate Exercise Source File</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Plan-a-robot-path.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Plan-a-robot-path.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Plan-a-robot-path.html#api-references">API References</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../demo2/Run-a-robot-path.html">Demo 2.9 - Run a Robot Path</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Run-a-robot-path.html#locate-exercise-source-file">Locate Exercise Source File</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Run-a-robot-path.html#complete-code">Complete Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Run-a-robot-path.html#build-code-and-run">Build Code and Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="../demo2/Run-a-robot-path.html#api-references">API References</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html">Exercise 5.0 - Advanced Descartes Path Planning</a><ul>
<li class="toctree-l2"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#reference-example">Reference Example</a></li>
<li class="toctree-l2"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#setup-workspace">Setup workspace</a></li>
<li class="toctree-l3"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#update-your-workcell-xacro-file">Update your workcell.xacro file.</a></li>
<li class="toctree-l3"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#add-new-planning-group-to-your-moveit-config-package">Add new planning group to your moveit_config package.</a></li>
<li class="toctree-l3"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#complete-advanced-descartes-node">Complete Advanced Descartes Node</a></li>
<li class="toctree-l3"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#update-the-setup-launch-file">Update the setup.launch file.</a></li>
<li class="toctree-l3"><a class="reference internal" href="Advanced-Descartes-Path-Planning.html#test-full-application">Test Full Application</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="Building-a-Perception-Pipeline.html">Exercise 5.1 - Building a Perception Pipeline</a><ul>
<li class="toctree-l2"><a class="reference internal" href="Building-a-Perception-Pipeline.html#prepare-new-workspace">Prepare New Workspace:</a></li>
<li class="toctree-l2"><a class="reference internal" href="Building-a-Perception-Pipeline.html#intro-review-existing-code">Intro (Review Existing Code)</a></li>
<li class="toctree-l2"><a class="reference internal" href="Building-a-Perception-Pipeline.html#primary-task-filling-in-the-blanks">Primary Task: Filling in the blanks</a><ul>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#implement-voxel-filter">Implement Voxel Filter</a><ul>
<li class="toctree-l4"><a class="reference internal" href="Building-a-Perception-Pipeline.html#viewing-results">Viewing Results</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#implement-pass-through-filters">Implement Pass-through Filters</a></li>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#plane-segmentation">Plane Segmentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#euclidean-cluster-extraction-optional-but-recommended">Euclidean Cluster Extraction (optional, but recommended)</a></li>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#create-a-cropbox-filter">Create a CropBox Filter</a></li>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#create-a-statistical-outlier-removal">Create a Statistical Outlier Removal</a></li>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#create-a-broadcast-transform">Create a Broadcast Transform</a></li>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#create-a-polygonal-segmentation">Create a Polygonal Segmentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="Building-a-Perception-Pipeline.html#write-a-launch-file">Write a launch file</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="Introduction-to-STOMP.html">Exercise 5.2 - Introduction to STOMP</a><ul>
<li class="toctree-l2"><a class="reference internal" href="Introduction-to-STOMP.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="Introduction-to-STOMP.html#information-and-resources">Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="Introduction-to-STOMP.html#objectives">Objectives</a></li>
<li class="toctree-l2"><a class="reference internal" href="Introduction-to-STOMP.html#setup">Setup</a></li>
<li class="toctree-l2"><a class="reference internal" href="Introduction-to-STOMP.html#add-stomp">Add STOMP</a><ul>
<li class="toctree-l3"><a class="reference internal" href="Introduction-to-STOMP.html#run-moveit-with-stomp">Run MoveIt! with STOMP</a></li>
<li class="toctree-l3"><a class="reference internal" href="Introduction-to-STOMP.html#explore-stomp">Explore STOMP</a></li>
<li class="toctree-l3"><a class="reference internal" href="Introduction-to-STOMP.html#configure-stomp">Configure STOMP</a></li>
<li class="toctree-l3"><a class="reference internal" href="Introduction-to-STOMP.html#more-info-on-the-stomp-parameters">More info on the STOMP parameters</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Exercise 5.3 - Simple PCL Interface for Python</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#prepare-new-workspace">Prepare New Workspace:</a></li>
<li class="toctree-l2"><a class="reference internal" href="#intro-review-existing-code">Intro (Review Existing Code)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#create-a-python-package">Create a Python Package</a></li>
<li class="toctree-l3"><a class="reference internal" href="#creating-setup-py">Creating setup.py</a></li>
<li class="toctree-l3"><a class="reference internal" href="#publishing-the-point-cloud">Publishing the Point Cloud</a></li>
<li class="toctree-l3"><a class="reference internal" href="#implement-a-voxel-filter">Implement a Voxel Filter</a></li>
<li class="toctree-l3"><a class="reference internal" href="#viewing-results">Viewing Results</a></li>
<li class="toctree-l3"><a class="reference internal" href="#implement-pass-through-filters">Implement Pass-Through Filters</a></li>
<li class="toctree-l3"><a class="reference internal" href="#plane-segmentation">Plane Segmentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="#euclidian-cluster-extraction">Euclidian Cluster Extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="#future-study">Future Study</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="OpenCV-in-Python.html">Exercise 5.4 - OpenCV Image Processing (Python)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="OpenCV-in-Python.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="OpenCV-in-Python.html#further-information-and-resources">Further Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="OpenCV-in-Python.html#problem-statement">Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="OpenCV-in-Python.html#implementation">Implementation</a><ul>
<li class="toctree-l3"><a class="reference internal" href="OpenCV-in-Python.html#create-package">Create package</a></li>
<li class="toctree-l3"><a class="reference internal" href="OpenCV-in-Python.html#create-an-image-publisher">Create an Image Publisher</a></li>
<li class="toctree-l3"><a class="reference internal" href="OpenCV-in-Python.html#create-the-detect-pump-image-processing-node">Create the Detect_Pump Image-Processing Node</a></li>
<li class="toctree-l3"><a class="reference internal" href="OpenCV-in-Python.html#challenge-exercises">Challenge Exercises</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../session6/Documentation-Generation.html">Exercise 6.0 - Documentation Generation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session6/Documentation-Generation.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Documentation-Generation.html#information-and-resources">Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Documentation-Generation.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Documentation-Generation.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session6/Documentation-Generation.html#annotate-the-source-code">Annotate the Source Code</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session6/Documentation-Generation.html#generate-documentation">Generate documentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session6/Documentation-Generation.html#view-the-documentation">View the Documentation</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session6/Unit-Testing.html">Exercise 6.1 - Unit Testing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session6/Unit-Testing.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Unit-Testing.html#information-and-resources">Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Unit-Testing.html#problem-statement">Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Unit-Testing.html#guidance">Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session6/Unit-Testing.html#create-the-unit-test-frame-work">Create the unit test frame work</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session6/Unit-Testing.html#add-stock-publisher-tests">Add stock publisher tests</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session6/Unit-Testing.html#write-specific-unit-tests">Write specific unit tests</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session6/Using-rqt-tools-for-analysis.html">Exercise 6.2 - Using rqt tools for Analysis</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session6/Using-rqt-tools-for-analysis.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Using-rqt-tools-for-analysis.html#information-and-resources">Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Using-rqt-tools-for-analysis.html#problem-statement">Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Using-rqt-tools-for-analysis.html#guidance">Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session6/Using-rqt-tools-for-analysis.html#rqt-graph-view-node-interaction"><code class="docutils literal"><span class="pre">rqt_graph</span></code>: view node interaction</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session6/Using-rqt-tools-for-analysis.html#rqt-console-view-messages"><code class="docutils literal"><span class="pre">rqt_console</span></code>: view messages:</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session6/Using-rqt-tools-for-analysis.html#rqt-plot-view-data-plots"><code class="docutils literal"><span class="pre">rqt_plot</span></code>: view data plots</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session6/Style-Guide-and-ros_lint.html">Exercise 6.3 - ROS Style Guide and ros_lint</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session6/Style-Guide-and-ros_lint.html#motivation">Motivation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Style-Guide-and-ros_lint.html#information-and-resources">Information and Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Style-Guide-and-ros_lint.html#scan-n-plan-application-problem-statement">Scan-N-Plan Application: Problem Statement</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Style-Guide-and-ros_lint.html#scan-n-plan-application-guidance">Scan-N-Plan Application: Guidance</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session6/Style-Guide-and-ros_lint.html#configure-package">Configure Package</a></li>
<li class="toctree-l3"><a class="reference internal" href="../session6/Style-Guide-and-ros_lint.html#run-roslint">Run roslint</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../session6/Docker-AWS.html">Exercise 6.4 - Introduction to ROS with Docker and Amazon Web Services (AWS)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../session6/Docker-AWS.html#demo-1-run-front-end-gazebo-host-and-back-end-in-docker">Demo #1 - Run front-end Gazebo host and back-end in Docker</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../session6/Docker-AWS.html#setup-workspace">Setup workspace</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../session6/Docker-AWS.html#front-end-run-on-host-and-only-contains-gui">Front-end (run on host and only contains gui)</a></li>
<li class="toctree-l4"><a class="reference internal" href="../session6/Docker-AWS.html#back-end-run-in-container">Back-end (run in container)</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../session6/Docker-AWS.html#running-the-demo">Running the Demo</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../session6/Docker-AWS.html#run-the-front-end">Run the front-end</a></li>
<li class="toctree-l4"><a class="reference internal" href="../session6/Docker-AWS.html#run-the-backend">Run the backend</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Docker-AWS.html#demo-2-run-front-end-on-a-web-server-and-back-end-in-docker">Demo #2 - Run front-end on a web-server and back-end in docker</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session6/Docker-AWS.html#demo-3-robot-web-tools">Demo #3 Robot Web Tools</a></li>
</ul>
</li>
</ul>

          
        
      </div>
      &nbsp;
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../../index.html">Industrial Training</a>
      </nav>

      
      <div class="wy-nav-content">

        <div class="header-override">
          <a href="http://rosindustrial.org">
            <img src="../../_static/logo.jpg"/>
          </a>
          <p>
            <a href="http://rosindustrial.org">ROS-Industrial Website</a>|<a href="http://rosindustrial.org/news">Blog</a>
          </p>
        </div>

        <div class="rst-content">
          <div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li class="wy-breadcrumbs-aside">
      
        
          <a href="https://github.com/ros-industrial/industrial_training/blob/kinetic/gh_pages/_source/session5/Simple-PCL-Interface-for-Python.rst" class="fa fa-github"> Edit on GitHub</a>
        
      
    </li>
    <li><a href="../../index.html">Docs</a> &raquo;</li>
      
    <li>Building a Simple PCL Interface for Python</li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             <div class="admonition note">
               <p class="first admonition-title">The code used in this tutorial is available!</p>
               <p class="last">Code can be found at <a href = "https://github.com/ros-industrial/industrial_training">industrial_training repository</a> in gh_pages folder. Use kinetic branch.</p>
             </div>

            
  <p>Code can be found at industrial_training repository in gh_pages folder. Use kinetic branch.</p>
<div class="section" id="building-a-simple-pcl-interface-for-python">
<h1>Building a Simple PCL Interface for Python<a class="headerlink" href="#building-a-simple-pcl-interface-for-python" title="Permalink to this headline">¶</a></h1>
<p>In this exercise, we will fill in the appropriate pieces of code to build a perception pipeline. The end goal will be to create point cloud filtering operations to demonstrate functionality between ROS and python.</p>
<div class="section" id="prepare-new-workspace">
<h2>Prepare New Workspace:<a class="headerlink" href="#prepare-new-workspace" title="Permalink to this headline">¶</a></h2>
<p>We will create a new catkin workspace, since this exercise does not overlap with the previous PlanNScan exercises.</p>
<ol class="arabic">
<li><p class="first">Disable automatic sourcing of your previous catkin workspace:</p>
<ol class="arabic simple">
<li><code class="docutils literal"><span class="pre">gedit</span> <span class="pre">~/.bashrc</span></code></li>
<li>comment out <code class="docutils literal"><span class="pre">#</span></code> the last line, sourcing your <code class="docutils literal"><span class="pre">~/catkin_ws/devel/setup.bash</span></code></li>
</ol>
<div class="highlight-bash"><div class="highlight"><pre><span class="nb">source</span> /opt/ros/kinetic/setup.bash
</pre></div>
</div>
</li>
<li><p class="first">Copy the template workspace layout and files:</p>
<div class="highlight-bash"><div class="highlight"><pre>cp -r ~/industrial_training/exercises/python-pcl_ws ~
<span class="nb">cd</span> ~/python-pcl_ws/
</pre></div>
</div>
</li>
<li><p class="first">Initialize and Build this new workspace</p>
<div class="highlight-bash"><div class="highlight"><pre>catkin init
catkin build
</pre></div>
</div>
</li>
<li><p class="first">Source the workspace</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nb">source</span> ~/python-pcl_ws/devel/setup.bash
</pre></div>
</div>
</li>
<li><p class="first">Download the PointCloud file and place the file in your home directory (~).</p>
</li>
<li><p class="first">Import the new workspace into your QTCreator IDE: In QTCreator: File -&gt; New Project -&gt; Import -&gt; Import ROS Workspace -&gt; ~/python-pcl_ws</p>
</li>
</ol>
</div>
<div class="section" id="intro-review-existing-code">
<h2>Intro (Review Existing Code)<a class="headerlink" href="#intro-review-existing-code" title="Permalink to this headline">¶</a></h2>
<p>Most of the infrastructure for a ros node has already been completed for you; the focus of this exercise is the perception algorithms/pipleline. The <cite>CMakelists.txt</cite> and <cite>package.xml</cite> are complete and a source file has been provided. You could build the source as is, but you would get errors. At this time we will explore the source code that has been provided - browse the provided <cite>py_perception_node.cpp</cite> file. This tutorial has been modified from training <a class="reference external" href="http://ros-industrial.github.io/industrial_training/_source/session5/Building-a-Perception-Pipeline.html">Exercise 5.1 Building a Perception Pipeline</a> and as such the C++ code has already been set up.  If something does not make sense, revisit that exercise.  Open up the preception_node.cpp file and look over the filtering functions.</p>
<div class="section" id="create-a-python-package">
<h3>Create a Python Package<a class="headerlink" href="#create-a-python-package" title="Permalink to this headline">¶</a></h3>
<p>Now that we have converted several filters to C++ functions, we are ready to call it from a Python node.  If you have not done so already, install PyCharm, community edition.  This IDE has the necessary parser for editing, without it, you will not be able to review any syntax issues in Qt.</p>
<ol class="arabic">
<li><p class="first">In the terminal, change the directory to your src folder. Create a new package inside your python-pcl_ws:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nb">cd</span> ~/python-pcl_ws/src/
catkin_create_pkg filter_call rospy roscpp perception_msgs
</pre></div>
</div>
</li>
<li><p class="first">Check that your package was created:</p>
<div class="highlight-bash"><div class="highlight"><pre>ls
</pre></div>
</div>
</li>
</ol>
<p>We will not be using ‘perception_msgs’ as we will not be creating custom messages in this course.  It is included for further student knowledge. If you wish for a more in depth explanation including how to implement customer messages, here is a good <a class="reference external" href="http://duckietown.mit.edu/media/pdfs/1rpRisFoCYUm0XT78j-nAYidlh-cDtLCdEbIaBCnx9ew.pdf">MIT resource</a> on the steps taken.</p>
<ol class="arabic">
<li><p class="first">Open <em>CMakeLists.txt</em>. You can open the file in Pycharm or Qt (or you can use nano, emacs, vim, or sublime). Uncomment line 23, and save.</p>
<div class="highlight-bash"><div class="highlight"><pre>catkin_python_setup<span class="o">()</span>
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="creating-setup-py">
<h3>Creating setup.py<a class="headerlink" href="#creating-setup-py" title="Permalink to this headline">¶</a></h3>
<p>The <cite>setup.py</cite> file makes your python module available to the entire workspace and subsequent packages.  By default, this isn’t created by the <cite>catkin_create_pkg</cite> command.</p>
<ol class="arabic">
<li><p class="first">In your terminal type</p>
<div class="highlight-bash"><div class="highlight"><pre>gedit filter_call/setup.py
</pre></div>
</div>
</li>
<li><p class="first">Copy and paste the following to the <cite>setup.py</cite> file (to paste into a terminal, Ctrl+Shift+V)</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c1">## ! DO NOT MANUALLY INVOKE THIS setup.py, USE CATKIN INSTEAD</span>
<span class="kn">from</span> <span class="nn">distutils.core</span> <span class="kn">import</span> <span class="n">setup</span>
<span class="kn">from</span> <span class="nn">catkin_pkg.python_setup</span> <span class="kn">import</span> <span class="n">generate_distutils_setup</span>
<span class="c1"># fetch values from package.xml</span>
<span class="n">setup_args</span> <span class="o">=</span> <span class="n">generate_distutils_setup</span><span class="p">(</span>
<span class="n">packages</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;&#39;</span><span class="p">],</span>
<span class="n">package_dir</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;&#39;</span><span class="p">:</span> <span class="s1">&#39;include&#39;</span><span class="p">},</span>
<span class="p">)</span>
<span class="n">setup</span><span class="p">(</span><span class="o">**</span><span class="n">setup_args</span><span class="p">)</span>
</pre></div>
</div>
<p>Change <code class="docutils literal"><span class="pre">packages</span> <span class="pre">=</span> <span class="pre">[</span> <span class="pre">.</span> <span class="pre">.</span> <span class="pre">.</span> <span class="pre">],</span></code> to your list of strings of the name of the folders inside your <em>include</em> folder.  By convention, this will be the same name as the package, or <code class="docutils literal"><span class="pre">filter_call</span></code> . The configures <code class="docutils literal"><span class="pre">filter_call/include/filter_call</span></code> as a python module available to the whole workspace.</p>
</li>
<li><p class="first">Save and close the file.</p>
<blockquote>
<div><p>In order for this folder to be accessed by any other python script, the <code class="docutils literal"><span class="pre">\__init__.py</span></code> file must exist.</p>
</div></blockquote>
</li>
<li><p class="first">Create one in the terminal by typing:</p>
<div class="highlight-bash"><div class="highlight"><pre>touch filter_call/include/filter_call/__init__.py
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="publishing-the-point-cloud">
<h3>Publishing the Point Cloud<a class="headerlink" href="#publishing-the-point-cloud" title="Permalink to this headline">¶</a></h3>
<p>As iterated before, we are creating a ROS C++ node to filter the point cloud when requested by a Python node running a service request for each filtering operation, resulting in a new, aggregated point cloud.  Let’s start with modifying our C++ code to publish in a manner supportive to python. Remember, the C++ code is already done so all you need to do is write your python script and view the results in rviz.</p>
</div>
<div class="section" id="implement-a-voxel-filter">
<h3>Implement a Voxel Filter<a class="headerlink" href="#implement-a-voxel-filter" title="Permalink to this headline">¶</a></h3>
<ol class="arabic">
<li><p class="first">In <em>py_perception_node.cpp</em>, uncomment the boolean function called <code class="docutils literal"><span class="pre">filterCallBack</span></code> (just above``main``) which performs in the service. This will be the service used by the python client to run subsequent filtering operations.</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">bool</span> <span class="nf">filterCallback</span><span class="p">(</span><span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">&amp;</span> <span class="n">request</span><span class="p">,</span>
                    <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Response</span><span class="o">&amp;</span> <span class="n">response</span><span class="p">)</span>
<span class="p">{</span>
  <span class="n">pcl</span><span class="o">::</span><span class="n">PointCloud</span><span class="o">&lt;</span><span class="n">pcl</span><span class="o">::</span><span class="n">PointXYZ</span><span class="o">&gt;::</span><span class="n">Ptr</span> <span class="n">cloud</span> <span class="p">(</span><span class="k">new</span> <span class="n">pcl</span><span class="o">::</span><span class="n">PointCloud</span><span class="o">&lt;</span><span class="n">pcl</span><span class="o">::</span><span class="n">PointXYZ</span><span class="o">&gt;</span><span class="p">);</span>
  <span class="n">pcl</span><span class="o">::</span><span class="n">PointCloud</span><span class="o">&lt;</span><span class="n">pcl</span><span class="o">::</span><span class="n">PointXYZ</span><span class="o">&gt;::</span><span class="n">Ptr</span> <span class="n">filtered_cloud</span> <span class="p">(</span><span class="k">new</span> <span class="n">pcl</span><span class="o">::</span><span class="n">PointCloud</span><span class="o">&lt;</span><span class="n">pcl</span><span class="o">::</span><span class="n">PointXYZ</span><span class="o">&gt;</span><span class="p">);</span>

  <span class="k">if</span> <span class="p">(</span><span class="n">request</span><span class="p">.</span><span class="n">pcdfilename</span><span class="p">.</span><span class="n">empty</span><span class="p">())</span>
  <span class="p">{</span>
    <span class="n">pcl</span><span class="o">::</span><span class="n">fromROSMsg</span><span class="p">(</span><span class="n">request</span><span class="p">.</span><span class="n">input_cloud</span><span class="p">,</span> <span class="o">*</span><span class="n">cloud</span><span class="p">);</span>
    <span class="n">ROS_INFO_STREAM</span><span class="p">(</span><span class="s">&quot;cloud size: &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">cloud</span><span class="o">-&gt;</span><span class="n">size</span><span class="p">());</span>
  <span class="p">}</span>
  <span class="k">else</span>
  <span class="p">{</span>
    <span class="n">pcl</span><span class="o">::</span><span class="n">io</span><span class="o">::</span><span class="n">loadPCDFile</span><span class="p">(</span><span class="n">request</span><span class="p">.</span><span class="n">pcdfilename</span><span class="p">,</span> <span class="o">*</span><span class="n">cloud</span><span class="p">);</span>
  <span class="p">}</span>

  <span class="k">if</span> <span class="p">(</span><span class="n">cloud</span><span class="o">-&gt;</span><span class="n">empty</span><span class="p">())</span>
  <span class="p">{</span>
    <span class="n">ROS_ERROR</span><span class="p">(</span><span class="s">&quot;input cloud empty&quot;</span><span class="p">);</span>
    <span class="n">response</span><span class="p">.</span><span class="n">success</span> <span class="o">=</span> <span class="nb">false</span><span class="p">;</span>
    <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
  <span class="p">}</span>

  <span class="k">switch</span> <span class="p">(</span><span class="n">request</span><span class="p">.</span><span class="n">operation</span><span class="p">)</span>
  <span class="p">{</span>

    <span class="k">case</span> <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">::</span><span class="nl">VOXELGRID</span> <span class="p">:</span>
    <span class="p">{</span>
      <span class="n">filtered_cloud</span> <span class="o">=</span> <span class="n">voxelGrid</span><span class="p">(</span><span class="n">cloud</span><span class="p">,</span> <span class="mf">0.01</span><span class="p">);</span>
      <span class="k">break</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="k">default</span> <span class="o">:</span>
    <span class="p">{</span>
      <span class="n">ROS_ERROR</span><span class="p">(</span><span class="s">&quot;No valid request found&quot;</span><span class="p">);</span>
      <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
    <span class="p">}</span>

   <span class="p">}</span>

<span class="cm">/*</span>
<span class="cm"> * SETUP RESPONSE</span>
<span class="cm"> */</span>
  <span class="n">pcl</span><span class="o">::</span><span class="n">toROSMsg</span><span class="p">(</span><span class="o">*</span><span class="n">filtered_cloud</span><span class="p">,</span> <span class="n">response</span><span class="p">.</span><span class="n">output_cloud</span><span class="p">);</span>
  <span class="n">response</span><span class="p">.</span><span class="n">output_cloud</span><span class="p">.</span><span class="n">header</span><span class="o">=</span><span class="n">request</span><span class="p">.</span><span class="n">input_cloud</span><span class="p">.</span><span class="n">header</span><span class="p">;</span>
  <span class="n">response</span><span class="p">.</span><span class="n">output_cloud</span><span class="p">.</span><span class="n">header</span><span class="p">.</span><span class="n">frame_id</span><span class="o">=</span><span class="s">&quot;kinect_link&quot;</span><span class="p">;</span>
  <span class="n">response</span><span class="p">.</span><span class="n">success</span> <span class="o">=</span> <span class="nb">true</span><span class="p">;</span>
  <span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p class="first">Within <code class="docutils literal"><span class="pre">main</span></code>, uncomment line 240. Save and build.</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="n">priv_nh_</span><span class="p">.</span><span class="n">param</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;leaf_size&quot;</span><span class="p">,</span> <span class="n">leaf_size_</span><span class="p">,</span> <span class="mf">0.0f</span><span class="p">);</span>
</pre></div>
</div>
</li>
<li><p class="first">Now that we have the framework for the filtering, open your terminal. Make sure you are in the filter_call directory. Create a <em>scripts</em> folder.</p>
<div class="highlight-bash"><div class="highlight"><pre>mkdir scripts
</pre></div>
</div>
</li>
<li><p class="first">If Pycharm is still open, save and close.  We need to open Pycharm from the terminal to make sure it is sourced correctly for C++ node to be heard.  To open, source to the pycharm install directory:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nb">cd</span> ~/pycharm-community-2018.1.3/bin
./pycharm.sh
</pre></div>
</div>
<p>Once open, locate and right click on the folder <em>scripts</em> and create a new python file.  Call it <em>filter_call.py</em></p>
</li>
<li><p class="first">Copy and paste the following code at the top of <em>filter_call.py</em> to import necessary libraries:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="ch">#!/usr/bin/env python</span>

<span class="kn">import</span> <span class="nn">rospy</span>
<span class="kn">import</span> <span class="nn">lesson_perception.srv</span>
<span class="kn">from</span> <span class="nn">sensor_msgs.msg</span> <span class="kn">import</span> <span class="n">PointCloud2</span>
</pre></div>
</div>
</li>
<li><p class="first">We will create an <code class="docutils literal"><span class="pre">if</span></code> statement to run our python node when this file is executed. Initalize as follows:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="k">try</span><span class="p">:</span>

    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="k">print</span><span class="p">(</span><span class="s2">&quot;Service call failed: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
</pre></div>
</div>
</li>
<li><p class="first">Include a <code class="docutils literal"><span class="pre">rospy.spin()</span></code> in the <code class="docutils literal"><span class="pre">try</span></code> block to look like the following:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">rospy</span><span class="o">.</span><span class="n">spin</span><span class="p">()</span>
    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="k">print</span><span class="p">(</span><span class="s2">&quot;Service call failed: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
</pre></div>
</div>
</li>
<li><p class="first">Copy and paste the following inside the <code class="docutils literal"><span class="pre">try</span></code> block:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c1"># =======================</span>
<span class="c1"># VOXEL GRID FILTER</span>
<span class="c1"># =======================</span>

<span class="n">srvp</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">ServiceProxy</span><span class="p">(</span><span class="s1">&#39;filter_cloud&#39;</span><span class="p">,</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloud</span><span class="p">)</span>
<span class="n">req</span> <span class="o">=</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloudRequest</span><span class="p">()</span>
<span class="n">req</span><span class="o">.</span><span class="n">pcdfilename</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">get_param</span><span class="p">(</span><span class="s1">&#39;~pcdfilename&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
<span class="n">req</span><span class="o">.</span><span class="n">operation</span> <span class="o">=</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloudRequest</span><span class="o">.</span><span class="n">VOXELGRID</span>
<span class="c1"># FROM THE SERVICE, ASSIGN POINTS</span>
<span class="n">req</span><span class="o">.</span><span class="n">input_cloud</span> <span class="o">=</span> <span class="n">PointCloud2</span><span class="p">()</span>

<span class="c1"># ERROR HANDLING</span>
<span class="k">if</span> <span class="n">req</span><span class="o">.</span><span class="n">pcdfilename</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
    <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">&#39;No file parameter found&#39;</span><span class="p">)</span>

<span class="c1"># PACKAGE THE FILTERED POINTCLOUD2 TO BE PUBLISHED</span>
<span class="n">res_voxel</span> <span class="o">=</span> <span class="n">srvp</span><span class="p">(</span><span class="n">req</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s1">&#39;response received&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">res_voxel</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
    <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">&#39;Unsuccessful voxel grid filter operation&#39;</span><span class="p">)</span>

<span class="c1"># PUBLISH VOXEL FILTERED POINTCLOUD2</span>
<span class="n">pub</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">Publisher</span><span class="p">(</span><span class="s1">&#39;/perception_voxelGrid&#39;</span><span class="p">,</span> <span class="n">PointCloud2</span><span class="p">,</span> <span class="n">queue_size</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">latch</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">pub</span><span class="o">.</span><span class="n">publish</span><span class="p">(</span><span class="n">res_voxel</span><span class="o">.</span><span class="n">output_cloud</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s2">&quot;published: voxel grid filter response&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Paste the following lines above the <code class="docutils literal"><span class="pre">try</span></code> block (still within the <code class="docutils literal"><span class="pre">if</span></code> statement) to initialize the python node and wait for the C++ node’s service.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">rospy</span><span class="o">.</span><span class="n">init_node</span><span class="p">(</span><span class="s1">&#39;filter_cloud&#39;</span><span class="p">,</span> <span class="n">anonymous</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">rospy</span><span class="o">.</span><span class="n">wait_for_service</span><span class="p">(</span><span class="s1">&#39;filter_cloud&#39;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">We need to make the python file executable. In your terminal:</p>
<div class="highlight-bash"><div class="highlight"><pre>chmod +x filter_call/scripts/filter_call.py
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="viewing-results">
<h3>Viewing Results<a class="headerlink" href="#viewing-results" title="Permalink to this headline">¶</a></h3>
<ol class="arabic">
<li><p class="first">In your terminal, run</p>
<div class="highlight-bash"><div class="highlight"><pre>roscore
</pre></div>
</div>
</li>
<li><p class="first">Source a new terminal and run the C++ filter service node</p>
<div class="highlight-bash"><div class="highlight"><pre>rosrun lesson_perception py_perception_node
</pre></div>
</div>
</li>
<li><p class="first">Source a new terminal and run the python service caller node. Note your file path may be different.</p>
<div class="highlight-bash"><div class="highlight"><pre>rosrun filter_call filter_call.py _pcdfilename:<span class="o">=</span><span class="s2">&quot;/home/ros-industrial/catkin_ws/table.pcd&quot;</span>
</pre></div>
</div>
</li>
<li><p class="first">Source a new terminal and run rviz</p>
<div class="highlight-bash"><div class="highlight"><pre>rosrun rviz rviz
</pre></div>
</div>
</li>
<li><p class="first">Add a new PointCloud2 in rviz</p>
</li>
<li><p class="first">In global options, change the fixed frame to kinect_link, and in the PointCloud 2, select your topic to be ‘/perception_voxelGrid’</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You may need to uncheck and recheck the PointCloud2.</p>
</div>
</li>
</ol>
</div>
<div class="section" id="implement-pass-through-filters">
<h3>Implement Pass-Through Filters<a class="headerlink" href="#implement-pass-through-filters" title="Permalink to this headline">¶</a></h3>
<ol class="arabic">
<li><p class="first">In <em>py_perception_node.cpp</em> in the <code class="docutils literal"><span class="pre">lesson_perception</span></code> package, within <code class="docutils literal"><span class="pre">main</span></code>, uncomment these two lines as well as their intilizations on lines 28 and 29.</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="n">priv_nh_</span><span class="p">.</span><span class="n">param</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;passThrough_max&quot;</span><span class="p">,</span> <span class="n">passThrough_max_</span><span class="p">,</span> <span class="mf">1.0f</span><span class="p">);</span>
<span class="n">priv_nh_</span><span class="p">.</span><span class="n">param</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;passThrough_min&quot;</span><span class="p">,</span> <span class="n">passThrough_min_</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0f</span><span class="p">);</span>
</pre></div>
</div>
</li>
<li><p class="first">Update the switch to look as shown below:</p>
<div class="highlight-bash"><div class="highlight"><pre>switch <span class="o">(</span>request.operation<span class="o">)</span>
<span class="o">{</span>

  <span class="k">case</span> lesson_perception::FilterCloud::Request::VOXELGRID :
  <span class="o">{</span>
    <span class="nv">filtered_cloud</span> <span class="o">=</span> voxelGrid<span class="o">(</span>cloud, 0.01<span class="o">)</span><span class="p">;</span>
    break<span class="p">;</span>
  <span class="o">}</span>
  <span class="k">case</span> lesson_perception::FilterCloud::Request::PASSTHROUGH :
  <span class="o">{</span>
    <span class="nv">filtered_cloud</span> <span class="o">=</span> passThrough<span class="o">(</span>cloud<span class="o">)</span><span class="p">;</span>
    break<span class="p">;</span>
  <span class="o">}</span>
  default :
  <span class="o">{</span>
    ROS_ERROR<span class="o">(</span><span class="s2">&quot;No valid request found&quot;</span><span class="o">)</span><span class="p">;</span>
    <span class="k">return</span> false<span class="p">;</span>
  <span class="o">}</span>

<span class="o">}</span>
</pre></div>
</div>
</li>
<li><p class="first">Save and build</p>
<p><strong>Edit the Python Code</strong></p>
</li>
<li><p class="first">Open the python node and copy paste the following code after the voxel grid, before the <code class="docutils literal"><span class="pre">rospy.spin()</span></code>.  Keep care to maintain indents:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c1"># =======================</span>
<span class="c1"># PASSTHROUGH FILTER</span>
<span class="c1"># =======================</span>

<span class="n">srvp</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">ServiceProxy</span><span class="p">(</span><span class="s1">&#39;filter_cloud&#39;</span><span class="p">,</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloud</span><span class="p">)</span>
<span class="n">req</span> <span class="o">=</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloudRequest</span><span class="p">()</span>
<span class="n">req</span><span class="o">.</span><span class="n">pcdfilename</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">req</span><span class="o">.</span><span class="n">operation</span> <span class="o">=</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloudRequest</span><span class="o">.</span><span class="n">PASSTHROUGH</span>
<span class="c1"># FROM THE SERVICE, ASSIGN POINTS</span>
<span class="n">req</span><span class="o">.</span><span class="n">input_cloud</span> <span class="o">=</span> <span class="n">res_voxel</span><span class="o">.</span><span class="n">output_cloud</span>

<span class="c1"># PACKAGE THE FILTERED POINTCLOUD2 TO BE PUBLISHED</span>
<span class="n">res_pass</span> <span class="o">=</span> <span class="n">srvp</span><span class="p">(</span><span class="n">req</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s1">&#39;response received&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">res_voxel</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
    <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">&#39;Unsuccessful pass through filter operation&#39;</span><span class="p">)</span>

<span class="c1"># PUBLISH PASSTHROUGH FILTERED POINTCLOUD2</span>
<span class="n">pub</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">Publisher</span><span class="p">(</span><span class="s1">&#39;/perception_passThrough&#39;</span><span class="p">,</span> <span class="n">PointCloud2</span><span class="p">,</span> <span class="n">queue_size</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">latch</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">pub</span><span class="o">.</span><span class="n">publish</span><span class="p">(</span><span class="n">res_pass</span><span class="o">.</span><span class="n">output_cloud</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s2">&quot;published: pass through filter response&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Save and run from the terminal, repeating steps outlined for the voxel filter.</p>
<p>Within Rviz, compare PointCloud2 displays based on the <code class="docutils literal"><span class="pre">/kinect/depth_registered/points</span></code> (original camera data) and <code class="docutils literal"><span class="pre">perception_passThrough</span></code> (latest processing step) topics. Part of the original point cloud has been “clipped” out of the latest processing result.</p>
<p>When you are satisfied with the pass-through filter results, press Ctrl+C to kill the node. There is no need to close or kill the other terminals/nodes.</p>
</li>
</ol>
</div>
<div class="section" id="plane-segmentation">
<h3>Plane Segmentation<a class="headerlink" href="#plane-segmentation" title="Permalink to this headline">¶</a></h3>
<p>This method is one of the most useful for any application where the object is on a flat surface. In order to isolate the objects on a table, you perform a plane fit to the points, which finds the points which comprise the table, and then subtract those points so that you are left with only points corresponding to the object(s) above the table. This is the most complicated PCL method we will be using and it is actually a combination of two: the RANSAC segmentation model, and the extract indices tool. An in depth example can be found on the <a class="reference external" href="http://pointclouds.org/documentation/tutorials/planar_segmentation.php#planar-segmentation">PCL Plane Model Segmentation Tutorial</a>; otherwise you can copy the below code snippet.</p>
<ol class="arabic">
<li><p class="first">In py_perception_node.cpp, in <code class="docutils literal"><span class="pre">main</span></code>, uncomment the code below as well as their respective intilization parameters.</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="n">priv_nh_</span><span class="p">.</span><span class="n">param</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;maxIterations&quot;</span><span class="p">,</span> <span class="n">maxIterations_</span><span class="p">,</span> <span class="mf">200.0f</span><span class="p">);</span>
<span class="n">priv_nh_</span><span class="p">.</span><span class="n">param</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;distThreshold&quot;</span><span class="p">,</span> <span class="n">distThreshold_</span><span class="p">,</span> <span class="mf">0.01f</span><span class="p">);</span>
</pre></div>
</div>
</li>
<li><p class="first">Update the switch statement in <code class="docutils literal"><span class="pre">filterCallback</span></code> to look as shown below:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">switch</span> <span class="p">(</span><span class="n">request</span><span class="p">.</span><span class="n">operation</span><span class="p">)</span>
<span class="p">{</span>

  <span class="k">case</span> <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">::</span><span class="nl">VOXELGRID</span> <span class="p">:</span>
  <span class="p">{</span>
    <span class="n">filtered_cloud</span> <span class="o">=</span> <span class="n">voxelGrid</span><span class="p">(</span><span class="n">cloud</span><span class="p">,</span> <span class="mf">0.01</span><span class="p">);</span>
    <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">case</span> <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">::</span><span class="nl">PASSTHROUGH</span> <span class="p">:</span>
  <span class="p">{</span>
    <span class="n">filtered_cloud</span> <span class="o">=</span> <span class="n">passThrough</span><span class="p">(</span><span class="n">cloud</span><span class="p">);</span>
    <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">case</span> <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">::</span><span class="nl">PLANESEGMENTATION</span> <span class="p">:</span>
  <span class="p">{</span>
    <span class="n">filtered_cloud</span> <span class="o">=</span> <span class="n">planeSegmentation</span><span class="p">(</span><span class="n">cloud</span><span class="p">);</span>
    <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">default</span> <span class="o">:</span>
  <span class="p">{</span>
    <span class="n">ROS_ERROR</span><span class="p">(</span><span class="s">&quot;No valid request found&quot;</span><span class="p">);</span>
    <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
  <span class="p">}</span>

<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p class="first">Save and build</p>
<p><strong>Edit the Python Code</strong></p>
</li>
<li><p class="first">Copy paste the following code in filter_call.py, after the passthrough filter section.  Keep care to maintain indents:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c1"># =======================</span>
<span class="c1"># PLANE SEGMENTATION</span>
<span class="c1"># =======================</span>

<span class="n">srvp</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">ServiceProxy</span><span class="p">(</span><span class="s1">&#39;filter_cloud&#39;</span><span class="p">,</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloud</span><span class="p">)</span>
<span class="n">req</span> <span class="o">=</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloudRequest</span><span class="p">()</span>
<span class="n">req</span><span class="o">.</span><span class="n">pcdfilename</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">req</span><span class="o">.</span><span class="n">operation</span> <span class="o">=</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloudRequest</span><span class="o">.</span><span class="n">PLANESEGMENTATION</span>
<span class="c1"># FROM THE SERVICE, ASSIGN POINTS</span>
<span class="n">req</span><span class="o">.</span><span class="n">input_cloud</span> <span class="o">=</span> <span class="n">res_pass</span><span class="o">.</span><span class="n">output_cloud</span>

<span class="c1"># PACKAGE THE FILTERED POINTCLOUD2 TO BE PUBLISHED</span>
<span class="n">res_seg</span> <span class="o">=</span> <span class="n">srvp</span><span class="p">(</span><span class="n">req</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s1">&#39;response received&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">res_voxel</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
    <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">&#39;Unsuccessful plane segmentation operation&#39;</span><span class="p">)</span>

<span class="c1"># PUBLISH PLANESEGMENTATION FILTERED POINTCLOUD2</span>
<span class="n">pub</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">Publisher</span><span class="p">(</span><span class="s1">&#39;/perception_planeSegmentation&#39;</span><span class="p">,</span> <span class="n">PointCloud2</span><span class="p">,</span> <span class="n">queue_size</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">latch</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">pub</span><span class="o">.</span><span class="n">publish</span><span class="p">(</span><span class="n">res_seg</span><span class="o">.</span><span class="n">output_cloud</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s2">&quot;published: plane segmentation filter response&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Save and run from the terminal, repeating steps outlined for the voxel filter.</p>
<p>Within Rviz, compare PointCloud2 displays based on the <code class="docutils literal"><span class="pre">/kinect/depth_registered/points</span></code> (original camera data) and <code class="docutils literal"><span class="pre">perception_planeSegmentation</span></code> (latest processing step) topics. Only points lying above the table plane remain in the latest processing result.</p>
<ol class="arabic simple">
<li>When you are done viewing the results you can go back and change the ”setMaxIterations” and “setDistanceThreshold” parameter values to control how tightly the plane-fit classifies data as inliers/outliers, and view the results again. Try using values of <code class="docutils literal"><span class="pre">maxIterations=100</span></code> and <code class="docutils literal"><span class="pre">distThreshold=0.010</span></code></li>
<li>When you are satisfied with the plane segmentation results, use Ctrl+C to kill the node. There is no need to close or kill the other terminals/nodes.</li>
</ol>
</li>
</ol>
</div>
<div class="section" id="euclidian-cluster-extraction">
<h3>Euclidian Cluster Extraction<a class="headerlink" href="#euclidian-cluster-extraction" title="Permalink to this headline">¶</a></h3>
<p>This method is useful for any application where there are multiple objects. This is also a complicated PCL method. An in depth example can be found on the <a class="reference external" href="http://pointclouds.org/documentation/tutorials/cluster_extraction.php#cluster-extraction">PCL Euclidean Cluster Extration Tutorial</a>.</p>
<ol class="arabic">
<li><p class="first">In py_perception_node.cpp <code class="docutils literal"><span class="pre">main</span></code> uncomment the following plus their intilization parameters.</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="n">priv_nh_</span><span class="p">.</span><span class="n">param</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;clustTol&quot;</span><span class="p">,</span> <span class="n">clustTol_</span><span class="p">,</span> <span class="mf">0.01f</span><span class="p">);</span>
<span class="n">priv_nh_</span><span class="p">.</span><span class="n">param</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;clustMax&quot;</span><span class="p">,</span> <span class="n">clustMax_</span><span class="p">,</span> <span class="mf">10000.0</span><span class="p">);</span>
<span class="n">priv_nh_</span><span class="p">.</span><span class="n">param</span><span class="o">&lt;</span><span class="kt">double</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;clustMin&quot;</span><span class="p">,</span> <span class="n">clustMin_</span><span class="p">,</span> <span class="mf">300.0f</span><span class="p">);</span>
</pre></div>
</div>
</li>
<li><p class="first">Update the switch statement in <code class="docutils literal"><span class="pre">filterCallback</span></code> to look as shown below:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">switch</span> <span class="p">(</span><span class="n">request</span><span class="p">.</span><span class="n">operation</span><span class="p">)</span>
<span class="p">{</span>

  <span class="k">case</span> <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">::</span><span class="nl">VOXELGRID</span> <span class="p">:</span>
  <span class="p">{</span>
    <span class="n">filtered_cloud</span> <span class="o">=</span> <span class="n">voxelGrid</span><span class="p">(</span><span class="n">cloud</span><span class="p">,</span> <span class="mf">0.01</span><span class="p">);</span>
    <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">case</span> <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">::</span><span class="nl">PASSTHROUGH</span> <span class="p">:</span>
  <span class="p">{</span>
    <span class="n">filtered_cloud</span> <span class="o">=</span> <span class="n">passThrough</span><span class="p">(</span><span class="n">cloud</span><span class="p">);</span>
    <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">case</span> <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">::</span><span class="nl">PLANESEGMENTATION</span> <span class="p">:</span>
  <span class="p">{</span>
    <span class="n">filtered_cloud</span> <span class="o">=</span> <span class="n">planeSegmentation</span><span class="p">(</span><span class="n">cloud</span><span class="p">);</span>
    <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">case</span> <span class="n">lesson_perception</span><span class="o">::</span><span class="n">FilterCloud</span><span class="o">::</span><span class="n">Request</span><span class="o">::</span><span class="nl">CLUSTEREXTRACTION</span> <span class="p">:</span>
  <span class="p">{</span>
    <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">pcl</span><span class="o">::</span><span class="n">PointCloud</span><span class="o">&lt;</span><span class="n">pcl</span><span class="o">::</span><span class="n">PointXYZ</span><span class="o">&gt;::</span><span class="n">Ptr</span><span class="o">&gt;</span> <span class="n">temp</span> <span class="o">=</span><span class="n">clusterExtraction</span><span class="p">(</span><span class="n">cloud</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">temp</span><span class="p">.</span><span class="n">size</span><span class="p">()</span><span class="o">&gt;</span><span class="mi">0</span><span class="p">)</span>
    <span class="p">{</span>
      <span class="n">filtered_cloud</span> <span class="o">=</span> <span class="n">temp</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
    <span class="p">}</span>
    <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">default</span> <span class="o">:</span>
  <span class="p">{</span>
    <span class="n">ROS_ERROR</span><span class="p">(</span><span class="s">&quot;No valid request found&quot;</span><span class="p">);</span>
    <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
  <span class="p">}</span>

<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p class="first">Save and build</p>
<p><strong>Edit the Python Code</strong></p>
</li>
<li><p class="first">Copy paste the following code in filter_call.py after the plane segmentation section.  Keep care to maintain indents:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c1"># =======================</span>
<span class="c1"># CLUSTER EXTRACTION</span>
<span class="c1"># =======================</span>

<span class="n">srvp</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">ServiceProxy</span><span class="p">(</span><span class="s1">&#39;filter_cloud&#39;</span><span class="p">,</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloud</span><span class="p">)</span>
<span class="n">req</span> <span class="o">=</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloudRequest</span><span class="p">()</span>
<span class="n">req</span><span class="o">.</span><span class="n">pcdfilename</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">req</span><span class="o">.</span><span class="n">operation</span> <span class="o">=</span> <span class="n">lesson_perception</span><span class="o">.</span><span class="n">srv</span><span class="o">.</span><span class="n">FilterCloudRequest</span><span class="o">.</span><span class="n">CLUSTEREXTRACTION</span>
<span class="c1"># FROM THE SERVICE, ASSIGN POINTS</span>
<span class="n">req</span><span class="o">.</span><span class="n">input_cloud</span> <span class="o">=</span> <span class="n">res_seg</span><span class="o">.</span><span class="n">output_cloud</span>

<span class="c1"># PACKAGE THE FILTERED POINTCLOUD2 TO BE PUBLISHED</span>
<span class="n">res_cluster</span> <span class="o">=</span> <span class="n">srvp</span><span class="p">(</span><span class="n">req</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s1">&#39;response received&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">res_voxel</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
    <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">&#39;Unsuccessful cluster extraction operation&#39;</span><span class="p">)</span>

<span class="c1"># PUBLISH CLUSTEREXTRACTION FILTERED POINTCLOUD2</span>
<span class="n">pub</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">Publisher</span><span class="p">(</span><span class="s1">&#39;/perception_clusterExtraction&#39;</span><span class="p">,</span> <span class="n">PointCloud2</span><span class="p">,</span> <span class="n">queue_size</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">latch</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">pub</span><span class="o">.</span><span class="n">publish</span><span class="p">(</span><span class="n">res_cluster</span><span class="o">.</span><span class="n">output_cloud</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s2">&quot;published: cluster extraction filter response&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Save and run from the terminal, repeating steps outlined for the voxel filter.</p>
<ol class="arabic simple">
<li>When you are satisfied with the cluster extraction results, use Ctrl+C to kill the node. If you are done experimenting with this tutorial, you can kill the nodes running in the other terminals.</li>
</ol>
</li>
</ol>
</div>
<div class="section" id="future-study">
<h3>Future Study<a class="headerlink" href="#future-study" title="Permalink to this headline">¶</a></h3>
<p>The student is encouraged to convert <a class="reference external" href="http://ros-industrial.github.io/industrial_training/_source/session5/Building-a-Perception-Pipeline.html">Exercise 5.1</a> into callable functions and further refine the filtering operations.</p>
<p>Furthermore, for simplicity, the python code was repeated for each filtering instance. The student is encouraged to create a loop to handle the publishing instead of repeating large chunks of code.  The student can also leverage the full functionality of the parameter handling instead of just using defaults, can set those from python.  There are several more filtering operations not outlined here, if the student wants practice creating those function calls.</p>
</div>
</div>
</div>


            
            <div class="admonition note">
              <p class="first admonition-title">Open Source Feedback</p>
              <p class="last">See something that needs improvement? Please open a pull request on this <a href="https://github.com/ros-industrial/industrial_training/blob/kinetic/gh_pages/_source/session5/Simple-PCL-Interface-for-Python.rst" class="fa fa-github"> GitHub page</a></p>
            </div>
            
           </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="OpenCV-in-Python.html" class="btn btn-neutral float-right" title="OpenCV Image Processing (Python)" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="Introduction-to-STOMP.html" class="btn btn-neutral" title="Introduction to STOMP" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div class="footer-override">
    <a href="http://rosindustrial.org/ric">
      <img src="../../_static/footer.jpg"/>
    </a>
  </div>

  <div role="contentinfo">
    <p>
    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.

</footer>
        </div>
      </div>

    </section>

  </div>
  <script>
  var pre = document.getElementsByTagName('pre');
  for (var i = 0; i < pre.length; i++) {
    var button = document.createElement('button');
    button.className = 'btn-copyboard fa fa-copy btn';
    pre[i].before(button);
  }

  var clipboard = new Clipboard('.btn-copyboard', {
    target: function(trigger) {return trigger.nextElementSibling;}
  });

  function showSuccess(elem){elem.setAttribute('class','btn-copyboard fa fa-check btn');}
  function sleep (time) {
    return new Promise((resolve) => setTimeout(resolve, time));
  }
  clipboard.on('success',function(e){
    showSuccess(e.trigger);
    sleep(350).then(() => {e.clearSelection();
      e.trigger.setAttribute('class','btn-copyboard fa fa-copy btn');})
  });
  </script>

  
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
    <span class="rst-current-version" data-toggle="rst-current-version">
        <span class="fa fa-book"> Other Versions</span>
        v: kinetic
        <span class="fa fa-caret-down"></span>
    </span>
    <div class="rst-other-versions">
        <dl>
            <dt>Branches</dt>
            <dd><a href="../../kinetic/_source/session5/Simple-PCL-Interface-for-Python.html">kinetic</a></dd>
        </dl>
    </div>
</div>


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../../',
            VERSION:'',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="../../_static/jquery.js"></script>
      <script type="text/javascript" src="../../_static/underscore.js"></script>
      <script type="text/javascript" src="../../_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="../../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>